<template>
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <div class="info-title">{{goods.title}}</div>
    <div class="info-price">
      <div class="n-price">{{goods.newPrice}}</div>
      <div class="o-price">{{goods.oldPrice}}</div>
      <div v-if="goods.discount" class="discount">{{goods.discount}}</div>
    </div>
    <div class="info-other">
      <span>{{goods.columns[0]}}</span>
      <span>{{goods.columns[1]}}</span>
      <span>{{goods.services[goods.services.length-1].name}}</span>
    </div>
    <div class="info-service">
      <span class="info-service-item" v-for="index in goods.services.length-1" :key="index">
        <img :src="goods.services[index-1].icon" alt="">
        <span>{{goods.services[index-1].name}}</span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailBaseInfo',
  props: {
    goods: {
      type: Object,
      default() {
        return {}
      }
    }
  }
}
</script>

<style scoped>
  .base-info {
    margin-top: 15px;
    padding: 0 8px;
    color: #999;
    border-bottom: 5px solid #f2f5f8;
  }
  .info-title {
    font-weight: bold;
    font-size: 18px;
    color: #222;
  }
  .info-price {
    display: flex;
    align-items: center;
    margin-top: 10px;
  }
  .info-price .n-price {
    font-size: 24px;
    color: var(--color-high-text);
  }
  .info-price .o-price {
    position: relative;
    top: 4px;
    font-size: 13px;
    margin-left: 5px;
    text-decoration: line-through;
  }
  .info-price .discount{
    position: relative;
    top: -2px;
    font-size: 12px;
    padding: 3px 4px;
    margin-left: 5px;
    border-radius: 10px;
    background-color: var(--color-high-text);
    color: #fff;
  }
  .info-other {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding: 20px 0 8px;
    border-bottom: 2px solid #eee;
  }
  .info-service {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    font-size: 14px;
    color: #222;
  }
  .info-service img{
    width: 14px;
    height: 14px;
    vertical-align: top;
    margin-right: 5px;
  }
</style>